//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include<sstream>
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef	vector<int>             VI;
typedef	vector<bool>            VB;
typedef	vector<VI>              VVI;
typedef	vector<string>          VS;
typedef	pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef	pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

#ifdef _DEBUG
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#else
#define eprintf(...) assert (true)
#endif

const int MAXN = 12;
const int MAXM = 250010;
int p[MAXM];
int pn[MAXM];
int C[MAXN][MAXM];
const int alphabet = 256;
string s;
int cnt[MAXM];

int h,n;

void suffix_array(string s) {
	//preparing
	n = SZ(s);
	memset(cnt,0,sizeof(cnt));
	FOR(i,0,n)
		cnt[s[i]]++;
	FOR(i,1,alphabet)
		cnt[i] += cnt[i-1];
	RFOR(i,n,0)
		p[ --cnt[s[i]] ] = i;
	int Class;
	C[(6)%12][p[0]] = Class = 0;
	FOR(i,1,n) {
		if(s[p[i]]!=s[p[i-1]]) Class++;
		C[(6)%12][p[i]] = Class;
	}

	//main part
	
	for(h=0;(1<<h)<n;h++) {
		FOR(i,0,n)
			pn[i] = (p[i] - (1<<h) + n)%n;
		memset(cnt,0,sizeof(cnt));

		FOR(i,0,n)
			cnt[C[(h+6)%12][pn[i]]] ++;
		
		FOR(i,1,n)
			cnt[i] += cnt[i-1];
		
		RFOR(i,n,0)
			p[--cnt[C[(h+6)%12][pn[i]]]] = pn[i];
		
		C[(h+7)%12][p[0]] = Class = 0;
		FOR(i,1,n) {
			int p1 = (p[i-1]+(1<<h)+n)%n;
			int p2 = (p[i]+(1<<h)+n)%n;
			if( C[(h+6)%12][p1]<C[(h+6)%12][p2] || C[(h+6)%12][p[i-1]]<C[(h+6)%12][p[i]] ) Class++;
			C[(h+7)%12][p[i]] = Class;
		}
	}
}

int compare(int i, int j) {
	int res = 0;
	
	for(int H = h-1;H>=6;H--) {
		if(C[H-6][i]==C[H-6][j]) {
			res += (1<<H);
			i = (i+(1<<H))%n;
			j = (j+(1<<H))%n;
		}
	}
	int it = 0;
	while(it<128 && s[(i+it)%n]==s[(j+it)%n] )
		it++;
	res += it;
	return res;
}

int main()
{
	cin >> n;
	cin >> s;
	double t = (2+14)*sizeof(C[0]);
	t += MAXM * sizeof(s[0]);
	t /= 1024.0;
	t /= 1024.0;
	i64 res = 0;
	suffix_array(s);
	FOR(i,0,SZ(s)-1) {
		i64 t = compare(p[i],p[i+1]);
		t = min(t,n*1ll);
		res += t;
	}
	double ans = (res*1.0)/(n-1.0);
	printf("%.7lf\n",ans);
    return 0;
}